///*
// * Copyright 2020-2022 the original author or authors.
// *
// * Licensed under the Apache License, Version 2.0 (the "License");
// * you may not use this file except in compliance with the License.
// * You may obtain a copy of the License at
// *
// *      https://www.apache.org/licenses/LICENSE-2.0
// *
// * Unless required by applicable law or agreed to in writing, software
// * distributed under the License is distributed on an "AS IS" BASIS,
// * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// * See the License for the specific language governing permissions and
// * limitations under the License.
// */
//package com.xunlai.infra.permission.manager.sercurity;
//
//import com.xunlai.infra.permission.common.util.SM2Utils;
//import org.springframework.beans.factory.annotation.Value;
//import org.springframework.context.annotation.Bean;
//import org.springframework.context.annotation.Configuration;
//import org.springframework.core.convert.converter.Converter;
//import org.springframework.security.authentication.AbstractAuthenticationToken;
//import org.springframework.security.config.annotation.method.configuration.EnableMethodSecurity;
//import org.springframework.security.config.annotation.web.builders.HttpSecurity;
//import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
//import org.springframework.security.config.annotation.web.configuration.WebSecurityCustomizer;
//import org.springframework.security.config.annotation.web.configurers.oauth2.server.resource.OAuth2ResourceServerConfigurer;
//import org.springframework.security.crypto.password.PasswordEncoder;
//import org.springframework.security.oauth2.jwt.Jwt;
//import org.springframework.security.oauth2.server.resource.authentication.JwtAuthenticationConverter;
//import org.springframework.security.web.SecurityFilterChain;
//import org.springframework.security.web.util.matcher.AntPathRequestMatcher;
//
//import static org.springframework.security.config.Customizer.withDefaults;
//
///**
// * @author Joe Grandja
// * @since 0.0.1
// */
//@EnableMethodSecurity
//@EnableWebSecurity
//@Configuration(proxyBeanMethods = false)
//public class SecurityConfig {
//
//	@Bean
//	WebSecurityCustomizer webSecurityCustomizer() {
//		return (web) -> web.ignoring().requestMatchers("/webjars/**");
//	}
//
//	@Bean
//	SecurityFilterChain securityFilterChain(HttpSecurity http) throws Exception {
//		http
////			.authorizeHttpRequests(authorize ->
////				authorize.anyRequest().authenticated()
////			)
//				.httpBasic(withDefaults())
////			.oauth2Login(oauth2Login -> {
////				oauth2Login.loginPage("/oauth2/authorization/adminmanager-client-oidc");
////				oauth2Login.userInfoEndpoint(userInfo -> userInfo.oidcUserService(new EnhanceOidcUserService()));
////			})
////				.logout(logout ->  logout.logoutRequestMatcher(new AntPathRequestMatcher("/logout", "GET")))
////			.oauth2Client(withDefaults())
////			.securityMatcher("/system/**")
//			.authorizeHttpRequests()
//					.requestMatchers("/system/**").hasAuthority("SCOPE_all")
////				.requestMatchers("/travel/**").permitAll()
//				.anyRequest().authenticated()
//			.and()
//			.oauth2ResourceServer(resourceServer -> {
//				JwtAuthenticationConverter jwtAuthenticationConverter = new JwtAuthenticationConverter();
//				jwtAuthenticationConverter.setJwtGrantedAuthoritiesConverter(new EnhanceJwtGrantedAuthoritiesConverter());
//				resourceServer.jwt().jwtAuthenticationConverter(jwtAuthenticationConverter);
//			})
//			;
//
//		return http.build();
//	}
//
////	@Bean
////	public PasswordEncoder passwordEncoder(@Value("${user.password.encoder.privateKey}") String privateKey, @Value("${user.password.encoder.publicKey}") String publicKey){
////		return new SM2PasswordEncoder(SM2Utils.loadPrivateKey(privateKey),SM2Utils.loadPublicKey(publicKey));
////	}
//}
